import { parse } from 'qs';

export function getPageQuery() {
  // parse 把地址？后面拼接参数字段解析成键值对的形式
  console.log(parse(window.location.href.split('?')[1]))
  return parse(window.location.href.split('?')[1]);
}
export function setAuthority(authority) {
  console.log(authority)
  const proAuthority = typeof authority === 'string' ? [authority] : authority;
  console.log(proAuthority)

  localStorage.setItem('antd-pro-authority', JSON.stringify(proAuthority)); // hard code
  // reload Authorized component
  try {
    if (window.reloadAuthorized) {
      window.reloadAuthorized();
    }
  } catch (error) {
    // do not need do anything
  }

  return authority;
}
